<template>
  <div class="unit">
    <!-- <div class="u-summary" v-text="unit.summary?unit.summary:'待输入'" v-if="name==='strategy'||name==='scenic'?false:true"></div> -->
    <div class="u-point" v-for="(pointItem, pointIndex) in unit" :key="pointIndex">
      <!-- point top -->
      <div class="point-top">
        <div class="p-t-left">
          <el-image
            class="ptl-img"
            lazy
            src="static/img/titImg.png"
            @load="load"
            @mousedown="mousedown"
            v-if="name==='strategy'||name==='scenic'?false:true"
          ></el-image>
          <span class="ptl-tit">{{pointItem.title}}</span>
        </div>
        <div class="p-t-right" v-if="name==='strategy'||name==='scenic'?false:true">
          <span class="ptr-time">游玩时长:{{pointItem.play_time}}h</span>
        </div>
      </div>
      <!-- point 图文混排 -->
      <!-- {{pointItem.content}} -->
      <div
        class="p-tibox"
        v-for="(contentItem, contentIndex) in pointItem.content"
        :key="contentIndex"
      >
        <div class="pt-text" v-if="contentItem.type === 'text'">
          <span v-html="replaceN(contentItem.val)"></span>
        </div>
        <div class="pt-img" v-else>
          <el-image :src="contentItem.imgList.url" @load="load" lazy @mousedown="mousedown" fit="cover"></el-image>
        </div>
      </div>
      <!-- point 资源 -->
      <div
        class="p-resource"
        v-for="(resourceItem, resourceIndex) in pointItem.resources"
        :key="resourceIndex+'point'"
      >
        <el-image
          class="pr-img"
          :src="resourceItem.thumb"
          lazy
          @load="load"
          @mousedown="mousedown"
          fit="cover"
        ></el-image>
        <div class="pr-info-group">
          <span class="pig-tit">{{resourceItem.title}}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
module.exports = {
  props: {
    unit: {
      type: Array,
      default: () => {
        return [];
      }
    },
    name: ''
  },
  methods: {
    replaceN(str) {
      if (str) {
        return str.replace(/\n/g, "<br>");
      }
    },
    load() {
      this.$emit("img-load");
    },
    mousedown(e) {
      e.preventDefault();
    }
  }
};
</script>
<style scoped>
.u-summary {
  margin-bottom: 20px;
}
.u-point {
  margin: 20px 0;
}
.point-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.p-t-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 3;
  margin-right: 2px;
}
.ptl-img {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  margin-right: 10px;
}
.ptl-tit {
  flex: 1;
  word-break: break-all;
  width: 100px;
  font-size: 18px;
  color: #353535;
  font-weight: bold;
}
.p-t-right {
  flex: 1.4;
}
.ptr-time {
  font-size: 12px;
  color: #8a8a8a;
}
/* 图文混排 */
.p-tibox {
  margin: 5px 0;
}
.pt-text {
  margin: 10px 0;
  font-size: 14px;
}
.pt-img {
  margin: 10px 0;
}
/* 资源 */
.p-resource {
  width: 100%;
  border-radius: 5px;
  background: #eeeeee;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 12px;
  margin: 5px 0;
}
.pr-img {
  width: 46px;
  height: 46px;
  border-radius: 4px;
  margin-right: 10px;
}
.pig-tit {
  font-size: 12px;
  /* font-weight: bold; */
}
</style>